package com.facebook 
{
	import flash.events.EventDispatcher;
	import flash.external.ExternalInterface;

	/**
	 * @author t.brault
	 */
	public class Facebook 
	{
		
		public static var dispatcher : EventDispatcher = new EventDispatcher();
		public static var flashId : String;
		
		public static function init ( $appId : String, $status : Boolean = true, $cookie : Boolean = true, $xfbml : Boolean = true ) : void
		{
			var obj : Object = {appId  : $appId, status : $status, cookie : $cookie, xfbml : $xfbml};
			ExternalInterface.call( 'FB.init', obj );
		}
		
		public static function api ( ...$params : Array ) : void
		{
			ExternalInterface.call( 'fbs_api', $params );
			ExternalInterface.addCallback( 'fbs_callback_api', function ( $args : Object ) { Facebook.dispatcher.dispatchEvent(new FacebookEvent(FacebookEvent.API,$args)); } );
		}
	}
}
